<?php

// phpinfo();exit;
try{
	// define('N_DEBUG', 0);
	
							
	include 'core/Init.php';
	//n_api("debug")->set('dev');	//[0:dev,1:test,2:alpha,3:beat,4:public]
	//print_r(pathinfo(N_PLUGINS.$_GET['path']));
	//exit;
	if(file_exists(N_PLUGINS.$_GET['path'])){
		$pathinfo = pathinfo(N_PLUGINS.$_GET['path']);
		switch ($pathinfo['extension']) {
			case 'js':
				$ctype = "application/javascript";
				break;
			case 'css':
				$ctype = "text/css";
				break;
			case 'gif':
				$ctype = "image/gif";
				break;
			case 'png':
				$ctype = "image/png";
				break;
			case 'jpg':
				$ctype = "image/jpg";
				break;
			
			default:
				$ctype = "";
				break;
		}

		header("Content-Type: $ctype");

		$lastModifiedTime = filemtime(N_PLUGINS.$_GET['path']); 
		$etag = md5_file(N_PLUGINS.$_GET['path']);

		header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModifiedTime)." GMT"); 
		header("Etag: $etag"); 
		if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && isset($_SERVER['HTTP_IF_NONE_MATCH'])){
			$modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
			$noneMath = trim($_SERVER['HTTP_IF_NONE_MATCH']);
			if ($modifiedSince == $lastModifiedTime || $noneMath == $etag) { 
				header("HTTP/1.1 304 Not Modified"); 
				exit; 
			}
		}
		


 		
//header('Content-type: text/css');

//header('Content-type: application/javascript'); 		
		echo file_get_contents(N_PLUGINS.$_GET['path']);
		exit;
	}
	header("HTTP/1.0 404 Not Found");
	
	exit;
	print_r($_GET);exit;
	$n = new Controller();
	if(!in_array(N_EVENT,array("OPEN","ERROR")) && N_SCRIPT!='cli'){
		n_api("manager")->startSession();
		//n_api("manager")->reloadPrivate();
	}
	$n->run();

	
}catch(CException $c){
	
	n_api("error")->fault($c);

}catch(PException $p){
	n_api("error")->alert($p);

}catch(exception $e){
	n_api('error')->ufo($e);

}


?>

